import torchvision
from torchvision import transforms
import cv2
import PIL
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
from torchvision import transforms as T

PIL_img = Image.open('../../images/lena.png')
OpenCV_img = cv2.imread('../../images/lena.png')
OpenCV_img = cv2.cvtColor(OpenCV_img, cv2.COLOR_BGR2RGB)

transform = T.Compose([
    T.ToTensor(),
])
print(PIL_img.size)
print(OpenCV_img.shape)
torch_img = transform(PIL_img)
print(torch_img.shape)

plt.figure(figsize=(10, 5))
plt.subplot(1, 3, 1)
plt.imshow(PIL_img)
plt.title('PIL')
plt.subplot(1, 3, 2)
plt.imshow(OpenCV_img)
plt.title('OpenCV')
plt.subplot(1, 3, 3)
plt.imshow(torch_img.permute(1, 2, 0))
plt.title('torchvision')
plt.show()